package midi;

import java.util.LinkedList;

import midi.IntervalOperations.interval;

public enum Chords {
	MajorTriad{ public interval[] getIntervals() { return MajorTriadIntervals; } },
	MinorTriad{ public interval[] getIntervals() { return MinorTriadIntervals; } },
	DiminishedTriad{ public interval[] getIntervals() { return DiminishedTriadIntervals; } },
	AugmentedTriad{ public interval[] getIntervals() { return AugmentedTriadIntervals; } };
	
	public MidiChord toMidiChord(Pitch rootPitch, int velocity, long length){
		LinkedList<MidiSound> soundList = new LinkedList<MidiSound>();
		soundList.add(new MidiSound(rootPitch, velocity));

		for (interval interval : this.getIntervals()){
			soundList.add(new MidiSound(rootPitch.raise(interval), velocity));
		}
		
		return new MidiChord(soundList, length);
	}
	
	public abstract interval[] getIntervals();
	
	private static interval[] MajorTriadIntervals = {interval.MajorThird, interval.PerfectFifth};
	private static interval[] MinorTriadIntervals = {interval.MinorThird, interval.PerfectFifth};
	private static interval[] DiminishedTriadIntervals = {interval.MinorThird, interval.AugFourth};
	private static interval[] AugmentedTriadIntervals = {interval.MajorThird, interval.MinorSixth};
}
